<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>鼠标跟随</title>
<script type="text/javascript">
		var newtop = 0;
		var newleft = 0;
		if(navigator.appName == "Netscape") {
			layerStyleRef = "layer.";
			layerRef = "document.layers";
			styleSwitch = "";
		} else {
			layerStyleRef = "layer.style.";
			layerRef = "document.all";
			styleSwitch = ".style";
		}
		function doMouseMove() {
			layerName = "iit";
			eval('var curElement=' + layerRef + '["' + layerName + '"]');
			eval(layerRef + '["' + layerName + '"]' + styleSwitch + '.visibility="hidden"');
			eval('curElement' + styleSwitch + '.visibility="visible"');
			eval('newleft=document.body.clientWidth-curElement' + styleSwitch + '.pixelWidth');
			eval('newtop=document.body.clientHeight-curElement' + styleSwitch + '.pixelHeight');
			eval('height=curElement' + styleSwitch + '.height');
			eval('width=curElement' + styleSwitch + '.width');
			width = parseInt(width);
			height = parseInt(height);

			if(event.clientX > (document.body.clientWidth - 5 - width)) {
				newleft = document.body.clientWidth + document.body.scrollLeft - 5 - width;
			} else {
				newleft = document.body.scrollWidth + event.clinetX;
			}
			eval('curElement' + styleSwitch + '.pixelLeft=newleft');
			if(event.clientY > (document.body.clientWidth - 5 - height)) {
				newleft = document.body.clientheight + document.body.scrollTop - 5 - height;
			} else {
				newleft = document.body.scrollTop + event.clinetY;
			}
			eval('curElement' + styleSwitch + '.pixelTop=newtop');
		}
		document.onmousemove = doMouseMove;
	</script>
</head>
<body>
	<h1>图片跟随鼠标</h1><hr>
	
	<script type="text/javascript">
		if (navigator.appName == "Netscape") {
		} else {
			document.write('<div id="outerDiv">');
			document.write('<img id="iit" src="a.gif" style="position:absolute; top:5pt; left:5pt; z-index:10; visibility:hidden;">');
			document.write('</div>');
		}
	</script>
</body>
</html>